<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitNewSeckill extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 抽奖签号
        Schema::create('seckill_activity', function (Blueprint $table) {

            $table->comment = '抽奖活动表';

            $table->increments('id');
            $table->uuid('uuid')->index() ;

            $table->string('title', 255)->nullable()->comment('标题'); // 标题
            $table->string('sub_title', 255)->nullable()->comment('副标题'); // 副标题
            $table->char('thumb', 255)->nullable()->comment('封面'); // 标题

            $table->integer('discount_money_price')->index()->nullable()->comment('人民币价格'); // 支付价格
            $table->integer('discount_score_price')->index()->nullable()->comment('积分价格'); // 支付价格

            $table->integer('money_price')->nullable()->comment('人民币价格'); // 支付价格
            $table->integer('score_price')->nullable()->comment('积分价格'); // 支付价格

            $table->integer('node_id')->index()->comment('绑定id');
            $table->uuid('node_uuid')->comment('绑定uuid');
            $table->char('node_type', 20)->index()->comment('绑定类型');

            $table->integer('user_group_id')->nullable()->comment('限制某人群可参与'); // 访问人数

            $table->integer('visit_total')->default(0)->comment('访问人数'); // 访问人数

            $table->integer('stock')->nullable()->comment('剩余库存'); // 剩余库存
            $table->integer('sales')->default(0)->comment('销量'); 

            $table->boolean('is_need_phone')->default(0)->comment('是否强制要求绑定手机号后可参与'); // none为免费 

            // $table->json('join_codes')->nullable()->comment('参与码'); // 参与码

            $table->timestamp('start_at')->nullable()->index()->comment('开始时间');
            $table->timestamp('end_at')->nullable()->index()->comment('结束时间');

            $table->integer('list_weight')->default(100)->index()->comment('权重');
            $table->tinyInteger('status')->index()->default(1)->nullable()->comment('0已下架 1为已上架');


            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::disableForeignKeyConstraints();
        Schema::dropIfExists('seckill_activity');
    }
}
